package com.chinatsp.onlineapp.utils;

import tsp.cn.http.tools.LogUtil;
import android.graphics.drawable.AnimationDrawable;
import android.util.Log;
import android.widget.ImageView;

import com.chinatsp.onlineapp.R;
import com.chinatsp.onlineapp.base.Config;

/**
 * 根据返回的weather_type，显示对应的状态
 */

public class WeatherType {

    /**
     * 根据weather_type, 显示状态图片
     */
    public static void showImg(String type, ImageView ivWeatherType) {
    	
    	
    	
        if (type.length()>2) {
        	String[] types = new String[2];
			types[0] = type.substring(0,2);
			types[1] = type.substring(2,4);
			type = types[0];
		}

        if (Config.WEATHER_SUNNY.equals(type)) {           //晴天
        	ivWeatherType.setBackgroundResource(R.drawable.sunny);
        }
        if (Config.WEATHER_CLOUDY.equals(type)) {          //多云
        	ivWeatherType.setBackgroundResource(R.drawable.cloudy);
        }
        if (Config.WEATHER_DUST.equals(type)) {            // 浮尘
        	ivWeatherType.setBackgroundResource(R.drawable.dust);
        }
        if (Config.WEATHER_DUST_SAND.equals(type)) {       // 扬沙
        	ivWeatherType.setBackgroundResource(R.drawable.dust_sand);
        }
        if (Config.WEATHER_FAG.equals(type)) {             // 雾
            ivWeatherType.setBackgroundResource(R.drawable.fag);
        }
        if (Config.WEATHER_HEAVY_RAIN.equals(type)) {      // 大雨
            ivWeatherType.setBackgroundResource(R.drawable.heavy_rain);
        }
        if (Config.WEATHER_HEAVY_RAIN0.equals(type)) {     // 大暴雨
            ivWeatherType.setBackgroundResource(R.drawable.heavy_rain0);
        }
        if (Config.WEATHER_HEAVY_SNOW.equals(type)) {      // 大雪
            ivWeatherType.setBackgroundResource(R.drawable.heavy_snow);
        }
        if (Config.WEATHER_HUGE_STORM.equals(type)) {       // 暴雪
            ivWeatherType.setBackgroundResource(R.drawable.huge_storm);
        }
        if (Config.WEATHER_X_HUGE_RAIN.equals(type)) {      // 暴雨
            ivWeatherType.setBackgroundResource(R.drawable.xhuge_rain);
        }
        if (Config.WEATHER_RAIN_AND_HAIL.equals(type)) {    // 阵雨加冰雹
            ivWeatherType.setBackgroundResource(R.drawable.rainandhail);
        }
        if (Config.WEATHER_OVERCAST.equals(type)) {          // 阴天
            ivWeatherType.setBackgroundResource(R.drawable.overcast);
        }
        if (Config.WEATHER_THUNDER_SHOWER.equals(type)) {    // 雷阵雨
            ivWeatherType.setBackgroundResource(R.drawable.thunder_shower);
        }
        
        

        

        AnimationDrawable spinner = (AnimationDrawable) ivWeatherType.getBackground();
        spinner.start();
    }
}
